package entity

import (
	"time"

	"shqsoft.cn/pasnj/base"

	"github.com/jinzhu/gorm"
)

//FDDR 房贷导入
type FDDR struct {
	ID    int        `gorm:"AUTO_INCREMENT;primary_key;column:ID"`
	KHYF  int        `gorm:"column:KHYF"`
	XH    int        `gorm:"column:XH"`
	CZJG  string     `gorm:"column:CZJG"`
	JJH   string     `gorm:"column:JJH"`
	KHMC  string     `gorm:"column:KHMC"`
	YWPZ  string     `gorm:"column:YWPZ"`
	BJZE  float64    `gorm:"column:BJZE"`
	FFR   *time.Time `gorm:"column:FFR;type:date"`
	DQR   *time.Time `gorm:"column:DQR;type:date"`
	FDLL  float64    `gorm:"column:FDLL"`
	ZXLL  float64    `gorm:"column:ZXLL"`
	JCDJ  float64    `gorm:"column:JCDJ"`
	KHJL1 string     `gorm:"column:KHJL1"`
	ZB1   float64    `gorm:"column:ZB1"`
	KHJL2 string     `gorm:"column:KHJL2"`
	ZB2   float64    `gorm:"column:ZB2"`
	KHJL3 string     `gorm:"column:KHJL3"`
	ZB3   float64    `gorm:"column:ZB3"`
	KHJL4 string     `gorm:"column:KHJL4"`
	ZB4   float64    `gorm:"column:ZB4"`
	DRJG  string     `gorm:"column:DRJG"`
}

//TableName 房贷导入
func (FDDR) TableName() string {
	return "T_BASE_YXFY_FD_DTIP"
}

//FdAfterImport 导入后执行分户处理
func FdAfterImport(tx *gorm.DB, params map[string]string) (err error) {
	prams := make([]interface{}, 1)
	prams[0] = params["KHYF"]
	tx.Exec("EXEC UP_BASE_YXFY_FD_DTIP ?", prams...)
	return nil
}

//FDDREF 返回结构体
func FDDREF() base.EntityFunc {
	return func() interface{} {
		entity := FDDR{}
		return &entity
	}
}

//FDDRESF 返回结构体数组
func FDDRESF() base.EntitiesFunc {
	return func() interface{} {
		var entities []FDDR
		return &entities
	}
}

func init() {
	base.DaoPoolObj.Put("FDDR", base.NewDefaultDao(FDDREF(), FDDRESF(), nil))
	base.SetAfterCallBack("FDDR", FdAfterImport)
}
